# l0 = [i for i in range(2000000)]
# print(l0, type(l0), l0.__sizeof__())
# for e in l0:
#     print(e)
# print(l0[-1])
from collections.abc import Iterable, Iterator, Generator

# t0 = (i for i in range(2000000))
# print(t0, type(t0), t0.__sizeof__())
# for e in t0:
#     print(e)

# print(isinstance(t0, Iterable), isinstance(t0, Iterator), isinstance(t0, Generator))



# def myfun1():
#     yield 1
#     yield 2
#     yield 3
#     return 100
#
# gen = myfun1()
# print(type(gen))
# # for e in gen:
# #     print(e)
#
# while True:
#     try:
#         e = next(gen)
#         print(e)
#     except StopIteration as e:
#         print(e)
#         break


# f = open("./26.练习题目.py")
# print(type(f), isinstance(f, Iterable), isinstance(f,Iterator), isinstance(f,Generator))
# f.close()


def read_file_by_gen():
    with open(f"./26.练习题目.py", encoding="utf8") as f:
        for line in f:
            print(f"读取........................")
            # 通过yield终端函数执行 每读取一行都中断一次  将内容放入生成器
            yield line


content = read_file_by_gen()
line = next(content)
print(line)
line = next(content)
print(line)
# line = next(content)
# print(line)
# line = next(content)
# print(line)
